﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfApp.Views;
using WpfApp.ViewModels;
using WpfApp.Services;

namespace WpfApp
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public static DataService data { get; set; }
        public MainWindow()
        {
            InitializeComponent();
            data = new DataService();
            
        }

        private void RegisterButton_Click(object sender, RoutedEventArgs e)
        {
            Register g = new Register();
            this.IsEnabled = false;
            g.Show();
        }

        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            string userName = nameBox.Text;
            string password = passWordBox.Password;
            if (userName == "" || password == "") MessageBox.Show("账号或密码不能为空！");
            else if (data.Login(userName,password))
            {
                MainMenu mainMenu = new MainMenu(userName);                
                mainMenu.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("账号或密码错误");
            }
            
        }

    }
}
